package com.analyse.stock.controller;

import com.analyse.stock.service.impl.FundFlowHistoryService;
import com.analyse.stock.service.impl.FundFlowRealRealTimeService;
import com.analyse.stock.vo.ResultUtils;
import com.analyse.stock.vo.ResultVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/fundFlowHistory")
public class FundFlowHistoryController {

    @Autowired
    private FundFlowHistoryService fundFlowHistoryService;

    @Autowired
    private FundFlowRealRealTimeService fundFlowRealRealTimeService;

    /**
     * 获取某个股票代码资金历史流向
     */
    @GetMapping("/getByCode")
    public ResultVo<String> getFlowByCode(@RequestParam(name="stockCode") String stockCode) {
        fundFlowHistoryService.pullFundFlowHistory(stockCode,0);
        return ResultUtils.success();
    }

    @GetMapping("/getLatestHis")
    public ResultVo<String> getLatestHis(@RequestParam(name="stockCode") String stockCode) {
        fundFlowHistoryService.pullFundFlowHistory(stockCode,1);
        return ResultUtils.success();
    }

    /**
     * 增量获取某个股票代码资金历史流向-当天统计数据
     */
    @GetMapping("/getLatest")
    public ResultVo<Integer> getLatest(@RequestParam(name="stockCodes") String stockCodes) {
        Integer num = fundFlowRealRealTimeService.getLatest(stockCodes);
        return ResultUtils.ok(num);
    }

    /**
     * 获取某个股票代码资金历史流向
     *//*
    @GetMapping("/getById")
    public ResultVo<String> getFlowById(@RequestParam(name="id") Integer id) {
        fundFlowHistoryService.getFlowById(id);
        return ResultUtils.success();
    }*/
}
